# coding:utf8
# 数学 - 工具类

import random
import re
import uuid

class UuidUtil:

    '''
        生成 id
    '''
    @staticmethod
    def toStr():
        uid = str(uuid.uuid4())
        suid = ''.join(uid.split('-'))
        return suid

'''
    验证码
'''
class CaptchaUtil:
    '''
        生成 随机数组 - array
    '''
    @staticmethod
    def toArray():
        s = []
        while len(s) < 4:
            x = random.randint(0, 9)
            if x not in s:
                s.append(str(x))
        return s

    '''
        生成 随机数组 - str
    '''
    @staticmethod
    def toStr():
        array = CaptchaUtil.toArray()
        return ''.join(array)



'''
    11位数字 - 暂为手机号
'''
class PhoneNumberUtil:
    '''
        生成 随机数组 - array
    '''
    @staticmethod
    def toArray():
        s = []
        while len(s) < 10:
            x = random.randint(0, 9)
            if x not in s:
                s.append(str(x))
        return s

    '''
        生成 随机数组 - str
    '''
    @staticmethod
    def toStr():
        array = PhoneNumberUtil.toArray()
        return '1'.__add__(''.join(array))

    '''
        验证手机号
    '''
    @staticmethod
    def check(tel) -> bool:

        ret = re.match(r"^1[3456789]\d{9}$", tel)
        if ret:
            return True
        else:
            return False
